#include <iostream>
#include <string>
#include <cstring>
#include <signal.h>
#include <unistd.h>
#include "KcpReceiver.h"

using namespace std;
bool bquit = false;

void sig_handler(int signo) {
    if (signo == SIGINT) {
        bquit = true;
    }
}

void recv_data(void *usr_data, const char*data, int len)
{
    KCPReceiver *p = (KCPReceiver*)usr_data;
    printf("recv data len:%d, %s\n", len, data);
}

int main() {
    KCPReceiver* receiver = new KCPReceiver();
    signal(SIGINT, sig_handler);
    receiver->SetInputCallback(recv_data);
    receiver->InitReceiver("127.0.0.1", 20000);
    while (!bquit) {
        sleep(5 * 1000);
    }
    delete receiver;
    return 0;
}